package net.oschina.app.holder;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import net.oschina.app.R;
import net.oschina.app.base.BaseHolder;
import net.oschina.app.base.Global;
import net.oschina.app.base.MyBaseAdapter;
import net.oschina.app.bean2.MoveCommentBean;
import net.oschina.app.protocol.Constant;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Vashon on 2017/1/13.
 */
public class MoveDetailHolder extends BaseHolder<MoveCommentBean.CommentBean> {
    @BindView(R.id.iv_move_item)
    CircleImageView mIvMoveItem;
    @BindView(R.id.tv_move_username)
    TextView mTvMoveUsername;
    @BindView(R.id.tv_move_time)
    TextView mTvMoveTime;
    @BindView(R.id.tv_move_content)
    TextView mTvMoveContent;

    public MoveDetailHolder(Context context, ViewGroup parent, MyBaseAdapter<MoveCommentBean.CommentBean> adapter, int position, MoveCommentBean.CommentBean bean) {
        super(context, parent, adapter, position, bean);
    }

    @Override
    public View onCreateView(Context context, ViewGroup parent) {
        View itemView = inflater.inflate(R.layout.item_move_detail, parent, false);
        ButterKnife.bind(this, itemView);
        return itemView;
    }

    @Override
    protected void onRefreshView(MoveCommentBean.CommentBean bean, int position) {

        String imageUrl = bean.getPortrait();
        if (imageUrl!=null) {
            imageUrl = imageUrl.replace("192.168.1.107:8080", Constant.GENYMOTION);
            Glide.with(Global.mContext).load(imageUrl).into(mIvMoveItem);
        }

        mTvMoveUsername.setText(bean.getAuthor());
        mTvMoveTime.setText(bean.getPubDate());
        mTvMoveContent.setText(bean.getContent());
    }
}
